package com.yxw.job.task.livevod;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.yxw.job.feign.client.CustomServiceFeignClient;
import com.yxw.live_vod_facade.feign.OnDemandFeignClient;
import com.yxw.yxnet_cd_center.common.utils.BaseDateTime;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 点播相关定时任务
 * liuxin
 * 2023.01.27
 */
@Component
@Slf4j
public class OnDemandVideoTask {


    @Autowired
    private OnDemandFeignClient onDemandFeignClient;

    /**
     * 点播点赞信息从redis添加到数据库
     *
     * @param str
     * @return
     */
    @XxlJob("addVodLikeRecord")
    public ReturnT<String> addVodLikeRecord(String str) {
        log.info("---------点播点赞信息从redis添加到数据库开始：--------" + BaseDateTime.getLongDateTimeString(new Date()));
         onDemandFeignClient.addLikeRecord();
        log.info("---------点播点赞信息从redis添加到数据库结束：--------" + BaseDateTime.getLongDateTimeString(new Date()));
        return ReturnT.SUCCESS;
    }

    @XxlJob("extractVodByDay")
    public ReturnT<String> extractVodByDay(String str) {
        log.info("---------抽取热门数据和最新数据放入缓存(每天凌晨执行一次)开始：--------" + BaseDateTime.getLongDateTimeString(new Date()));
        onDemandFeignClient.extractVodByDay();
        log.info("---------抽取热门数据和最新数据放入缓存(每天凌晨执行一次)结束：--------" + BaseDateTime.getLongDateTimeString(new Date()));
        return ReturnT.SUCCESS;
    }
}
